package com.fatdetection.demo.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fatdetection.demo.bean.School;
import com.fatdetection.demo.mapper.SchoolMapper;
import com.fatdetection.demo.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SchoolServiceImp implements SchoolService {

    @Autowired
    SchoolMapper schoolMapper;

    @Override
    public Boolean insertSchool(School school) {
        return schoolMapper.insert(school) == 1;
    }

    @Override
    public Boolean delSchool(String schoolName) {
        return schoolMapper.delete(new QueryWrapper<School>().eq("schoolName", schoolName)) == 1;
    }

    @Override
    public List<School> findAllSchool() {
        return schoolMapper.selectList(null);
    }

    @Override
    public School findSchoolByName(String name) {
        return schoolMapper.selectOne(new QueryWrapper<School>().eq("schoolName", name));
    }

    @Override
    public List<School> findSchoolByProvince(String province) {
        return schoolMapper.selectList(new QueryWrapper<School>().eq("province", province));

    }
}
